package client.presentation;

import java.awt.GridLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.JButton;
import javax.swing.JPanel;
import javax.vecmath.Quat4d;
import javax.vecmath.Vector3d;

import client.controller.Universe3DController;

public class TwoDCreator extends JPanel{

	private static final long serialVersionUID = 8864613406497770737L;

	private Universe3DController universe = null;
	private Vector3d position = null;
	private Quat4d orientation = null;
	
	public TwoDCreator(Universe3DController u) {
		universe = u;
		
		position = new Vector3d();
		orientation = new Quat4d();
		
		this.setLayout(new GridLayout(12,1));
		JButton cube = new JButton("Cube");
		JButton sphere = new JButton("Sphere");
		JButton cylindre = new JButton("Cylindre");
		JButton dolorean = new JButton("Dolorean");
		
		cube.addActionListener(new addCubeListener());
		sphere.addActionListener(new addSphereListener());
		cylindre.addActionListener(new addCylindreListener());
		dolorean.addActionListener(new addDoloreanListener());
		
		add(cube);
		add(sphere);
		add(cylindre);
		add(dolorean);
		setSize(80,360);
	}
	
	class addCubeListener implements ActionListener {
		public void actionPerformed(ActionEvent e) {
			universe.createObject("cube", position, orientation, "vrml/colorcube.wrl");
		}
	}
	
	class addSphereListener implements ActionListener {
		public void actionPerformed(ActionEvent e) {
			universe.createObject("sphere", position, orientation, "vrml/sphere.wrl");
		}
	}
	
	class addCylindreListener implements ActionListener {
		public void actionPerformed(ActionEvent e) {
			universe.createObject("cylindre", position, orientation, "vrml/cylinder.wrl");
		}
	}
	
	class addDoloreanListener implements ActionListener {
		public void actionPerformed(ActionEvent e) {
			universe.createObject("dolorean", position, orientation, "vrml/dolorean.wrl");
		}
	}
}
